﻿using System;
using Quartz;
using Quartz.Impl;

namespace ZYHand.Job
{
    class Program
    {

        private static ISchedulerFactory schedulerFactory;
        private static IScheduler scheduler;
        static void Main(string[] args)
        {
            var isexit = Console.ReadLine();
            while (isexit != "exit")
            {
                Console.WriteLine(isexit);
                schedulerFactory = new StdSchedulerFactory();
                scheduler = schedulerFactory.GetScheduler().Result;



                var trigger = TriggerBuilder.Create()
                               .WithSimpleSchedule(x => x.WithIntervalInSeconds(2).RepeatForever())//每两秒执行一次
                               .Build();
                //4、创建任务
                var jobDetail = JobBuilder.Create<MyJob>()
                                .WithIdentity("job", "group")
                                .Build();
                //5、将触发器和任务器绑定到调度器中
                scheduler.ScheduleJob(jobDetail, trigger);

                scheduler.Start();//放在后面启动

                Console.WriteLine("Hello World!");
                isexit=Console.ReadLine();
            }
        }
    }
}
